// ==================================================

// C library
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

// Containers
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

// Input/Output
#include <iostream>
#include <istream>
#include <ostream>
#include <sstream>
#include <fstream>
#include <ios>
#include <iomanip>

// Other
#include <tuple>
#include <string>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <utility>
#include <type_traits>
#include <iterator>
#include <limits>
#include <stdexcept>
#include <random>
#include <chrono>

// ==================================================

using namespace std;

using PII = pair<int, int>;
using LL = long long;
const LL oo = (1<<31 - 10);

// ==================================================

static auto _2333_ = []() {
                       ios::sync_with_stdio(false);
                       cin.tie(nullptr); return 0; }();

// ==================================================
#define max_(x, y) ((x) > (y) ? (x) : (y))
#define min_(x, y) ((x) > (y) ? (y) : (x))

#define PR(x) cout << #x " = " << (x) << "\t"
#define NL cout << "\n"

#define PRINT1(x) PR(x), NL
#define PRINT2(x1, x2) PR(x1), PRINT1(x2)
#define PRINT3(x1, x2, x3) PR(x1), PRINT2(x2, x3)
#define PRINT4(x1, x2, x3, x4) PR(x1), PRINT3(x2, x3, x4)

// ==================================================

template<typename T>
void PRINTC(const T& a) { cout << a << " "; }

template<typename T>
void PRINT_CONTAINER(const T& c) { for (auto &x : c) PRINTC(x); NL; }

template<typename T>
void PRINTV(const vector<T>& c) { PRINT_CONTAINER<vector<T>>(c); }

template<typename T>
void PRINTA(const T ar[], int n) {
  for (int i = 0; i < n; ++i) PRINTC(ar[i]); NL;
}

template<typename T1, typename T2>
void PRINTP(const pair<T1, T2>& p) { PRINTC(p.first); PRINTLN(p.second); }

template<typename T>
void PRINTLN(const T& a) { cout << a << "\n"; }

template< typename T1, typename T2 >
void PRINTAV( T1 & vec, T2 x) {
  ostream_iterator< T2 > O( cout, " " );
  copy( begin( vec ), end( vec ), O ); NL;
}

// ==================================================


struct cube {
  int a, b, c;
};
const int N = 120;
cube A[N];
LL d[N][N][N][4];

int H(int i, int k) {
  switch (k) {
  case 1:
    return A[i].c;
  case 2:
    return A[i].a;
  case 3:
    return A[i].b;
  }
  return 0;
}
int S(int i, int k) {
  switch (k) {
  case 1:
    return A[i].a * A[i].b;
  case 2:
    return A[i].b * A[i].c;
  case 3:
    return A[i].a * A[i].c;
  }
  return 0;
}

int main( void ) {

#ifdef DEBUG
  freopen("luogo5760.in", "r", stdin);
#endif

  int m, n;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> A[i].a >> A[i].b >> A[i].c;
  }

  for (int i = 1; i <= m; i++) {
    for (int a = 1; a <= n; a++) {
      for (int b = 1; b <= a; b++) {
        for (int k = 1; k <= 3; k++) {
          LL &res = d[i][a][b][k];
          res = max_(res, d[i][a-1][b][k]);
          
        }
      }
    }
  }

  return 0;
}
